
package com.shop.cloud.mall.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.cloud.common.core.constant.CacheConstants;
import com.shop.cloud.mall.common.entity.GoodsSku;
import com.shop.cloud.mall.admin.mapper.GoodsSkuMapper;
import com.shop.cloud.mall.admin.service.GoodsSkuService;
import org.springframework.boot.autoconfigure.klock.annotation.Klock;
import org.springframework.boot.autoconfigure.klock.model.LockTimeoutStrategy;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import java.io.Serializable;
import java.util.List;

/**
 * 商品sku
 *
 * @author
 * @date 2019-08-13 10:18:34
 */
@Service
public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> implements GoodsSkuService {

	@Override
	@Klock(name = "GoodsSku", keys = {"#entity.getId()"}, lockTimeoutStrategy = LockTimeoutStrategy.FAIL_FAST)
	@CacheEvict(value = CacheConstants.MALL_GOODS_SPU, key = "#entity.spuId")
	public boolean updateById(GoodsSku entity) {
		return super.updateById(entity);
	}

	@Override
	@Klock(name = "GoodsSku", keys = {"#updateWrapper.getEntity().getId()"}, lockTimeoutStrategy = LockTimeoutStrategy.FAIL_FAST)
	public boolean update(Wrapper<GoodsSku> updateWrapper) {
		return super.update(updateWrapper);
	}

	@Override
	@Klock(name = "GoodsSku", keys = {"#id"}, lockTimeoutStrategy = LockTimeoutStrategy.FAIL_FAST)
	public boolean removeById(Serializable id) {
		return super.removeById(id);
	}

	@Override
	public List<GoodsSku> listGoodsSkuBySpuId(String spuId) {
		return baseMapper.listGoodsSkuBySpuId(spuId);
	}
}
